package mf.com.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import mf.com.Service.FileUploadService;
import mf.com.vo.common.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: lmf
 * @Create: 2024/3/30 16:53
 * Description:  文件删除控制层
 */
@RestController
@RequestMapping("/admin/system")
@Tag(name = "文件上传")
public class FileUploadController {
    @Resource
    private FileUploadService fileUploadService;

    /**
     * 文件上传
     * MultipartFile file   file为上传文件流对应字段，需要和前端上传字段保持一致，，不可随意修改
     *
     * @param file 文件流
     * @return 文件访问地址
     */
    @PostMapping("/fileUpload")
    public Result<String> fileUpload(MultipartFile file) {
        System.out.println(file);
        return Result.success(fileUploadService.uploadFile(file));
    }
}
